package game;

import java.awt.Color;
import java.util.ArrayList;

public class ActionField extends Field {
	private static final long serialVersionUID = 1L;
	protected ArrayList<Object[]> sprites = new ArrayList<Object[]>();
	
	public ActionField(Level l, int x, int y, int w, int h, Color c){
		super(l,x,y,w,h,c);
	}
	
	public void update(){
		for(Object[] o: sprites){
			if((Boolean)o[0]){
				if(!(Boolean)o[1]){
					act((Sprite)o[2]);
					o[1] = true;
				}
			}else{
				sprites.remove(o);
			}
			o[0] = false;
		}
	}
	
	public void calculateIntersectEffects(GameRectangle g){
		if(g instanceof Sprite){
			Object[] temp = {true, false, (Sprite)g};
			for(Object[] o: sprites){
				if(o[2].equals(temp[2])){
					o[1] = true;
					o[0] = true;
					return;
				}
			}
			sprites.add(temp);
		}
	}
	
	public void addInfo(Object[] temp){
		for(Object[] o: sprites){
			if(o[2].equals(temp[2])){
				o[0] = true;
				o[1] = true;
				return;
			}
		}
		sprites.add(temp);
	}
	
	public void act(Sprite s){}
}
